package day04;

import java.util.Arrays;

public class ArrayCopyDemo {
    public static void main(String[] args) {
        int[] arr = {4,2,1};
        test02();
    }

    public static void copy(){
        int[] arr = {1,2,3};
        int[] temp = Arrays.copyOf(arr,4);

        temp[temp.length-1] = 100;

        System.out.println(Arrays.toString(arr));

        System.out.println(Arrays.toString(temp));
    }

    public static void test02(){
        int[] arr = {1,2,3};
        int[] temp = new int[arr.length+1];
        System.arraycopy(arr,0,temp,0,3);
        System.out.println(Arrays.toString(temp));
    }
}
